<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<script>
		function* f() {
			for(var i = 0; true; i++){
				var reset = yield i;
				if(reset) { i = -1};
			}
		}

		var g =f();

		console.log(g.next());	// {value:0, done:false}
		console.log(g.next());	// {value:1, done:false}
		console.log(g.next());	// {value:2, done:false}
		console.log(g.next(true));	// {value:0, done:false}
		console.log(g.next());	// {value:1, done:false}
	</script>
</head>
<body>
	
</body>
</html>